#ifndef _RESOURCE_MANAGER_H_
#define _RESOURCE_MANAGER_H_

#include "../resource/Resource.h"

/*
	class : ResourceManager
	desc : This class is the resource manager and is used
		to manage resources.
*/
class ResourceManager
{
	private:
		//vector used to keep track of resources and pairs them with an
		//id to tell who owns the resource right now.
		static Vector<Pair<Resource*, unsigned int>> resources;
		//tells who is using the resource
		static Vector<Pair<Resource*, Vector<unsigned int>>> resourceUsers;
		//gives the state of users.
		static Vector<Pair<Resource*, Vector<unsigned char>>> userStates;
	public:
		enum states { IDLE, WAITING, ACTIVE };	
		//default constructor
		ResourceManager(){}
		//registers a new resource returns a pair
		static Pair<Resource*, unsigned int>* registerResource(
							Resource* r);
		//gets the resource pair given the resource.
		//this gets the resource and the id of its current owner
		static Pair<Resource*, unsigned int>* getResource(Resource* r);

		//gets users of a resource
		static Pair<Resource*, Vector<unsigned int>>*
			getResourceUsers(Resource* r);

		//registers a user of a specific resource
		static Pair<Resource*, Vector<unsigned int>>*
			registerResourceUser(Resource* r, unsigned int user);

		//gets the set of states the users waiting for a resource are in.
		static Pair<Resource*, Vector<unsigned char>>*
			getResourceStates(Resource* r);
};
//
Vector<Pair<Resource*, unsigned int>> ResourceManager::resources = 
			Vector<Pair<Resource*, unsigned int>>();
Vector<Pair<Resource*, Vector<unsigned int>>> ResourceManager::resourceUsers = 
			Vector<Pair<Resource*, Vector<unsigned int>>>();

Vector<Pair<Resource*, Vector<unsigned char>>> ResourceManager::userStates =
			Vector<Pair<Resource*, Vector<unsigned char>>>();


#endif
